package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.pojo.WebConfig;
import com.itheima.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * @author xuchangshuo
 * @date 2020/8/3 18:52
 */
@RestController
@CrossOrigin
@RequestMapping("/webConfig")
public class ConfigController {
    @Autowired
    private ConfigService configService;

    //查询配置
    @RequestMapping("/getWebConfig")
    public Result getConfig() {
        List<WebConfig> config = configService.findConfig();
        WebConfig webConfig = config.get(0);
        return new Result("success", webConfig);
    }

    //编辑配置
    @PostMapping("/editWebConfig")
    public Result editWebConfig(@RequestBody Map<String,Object> commentVO) {
        configService.editWebConfig(commentVO);
        return new Result("success","编辑成功");
    }
}
